package com.cn.wanxi.dao.impl;

import com.cn.wanxi.dao.NewsDao;
import com.cn.wanxi.model.NewsModel;
import com.cn.wanxi.util.JDBC;

import java.util.ArrayList;
import java.util.List;

public class NewsImpl implements NewsDao {
    @Override
    public int add(NewsModel newsModel) {
//        String sql = "insert into news (name,create_time,content,enable) values " +
//                "('" + newsModel.getName() + "',now(),'','1')";
        String sql = "insert into news (name,create_time,content,enable) values " +
                "(?,now(),?,?)";
        List<Object> list = new ArrayList<>();
        list.add(newsModel.getName());
        list.add(newsModel.getContent());
        list.add(newsModel.getEnable());
//        注意：有多少？，就应该加多少个list.add，不能修改顺序
        return JDBC.update(sql, list);
    }

    @Override
    public int update(NewsModel newsModel) {
        return 0;
    }

    @Override
    public int delete(NewsModel newsModel) {
        return 0;
    }

    @Override
    public NewsModel findById(NewsModel newsModel) {
        return null;
    }

    @Override
    public List<NewsModel> findAll(NewsModel newsModel) {
        return null;
    }

    @Override
    public int getCount(NewsModel newsModel) {
        return 0;
    }
}
